package com.boot41.mapper;

import com.boot41.entity.Product;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author wxd
 * @version 1.0
 */
@Mapper
public interface ProductMapper {
    @Select("select * from product")
    @Result(column = "sale_count", property = "saleCount")
    List<Product> select();

    @Insert("insert into product values(null,#{title},#{price},#{saleCount})")
    void insert(Product product);

    @Delete("delete from product where id=#{id}")
    void deleteById(int id);

    @Select("select * from product where id=#{id}")
    @Result(column = "sale_count",property = "saleCount")
    Product selectById(int id);

    @Update("update product set title=#{title},price=#{price},sale_count=#{saleCount} where id=#{id}")
    void updateById(Product product);
}
